<docs>
  ## 编辑求职意向
</docs>
<template>
  <div class="wrap">
    <div class="tab-wrap">
      <div>
        <router-link :to="{ path: '/person/baseInfo/pBaseInfo'}">
        人员信息
        </router-link>
      </div>
       <div class="active">
          <router-link :to="{ path: '/person/baseInfo/jobIntent'}">
          求职意向
          </router-link>
      </div>
      <div @click="gzjl_link">
        <!-- <router-link :to="{ path: '/person/baseInfo/workHistory'}"> -->
          工作经历
        <!-- </router-link> -->
      </div>
      <div @click="xxjl_link">
        <!-- <router-link :to="{ path: '/person/baseInfo/schoolExper'}"> -->
          学习经历
        <!-- </router-link> -->
      </div>
      <div @click="qtxx_link">
        <!-- <router-link :to="{ path: '/person/baseInfo/otherInfo'}"> -->
          其他信息
        <!-- </router-link> -->
      </div>
    </div>
    <!-- 求职意向 -->
    <div class="common job_intent" v-for="(item, index) in qzyx" :key="index">
      <div class="title tem_comm">
        <p>求职意向</p>
        <div class="group">
          <i class="iconfont icon-delete"  @click="deleteData(item)">删除</i>
          <i class="iconfont icon-edit" @click="editJobIntent(2,item)">编辑</i>
        </div>
      </div>
      <div class="point tem_comm">
        <p class="item">
          <span class="list_l">岗位分类</span><span class="list_r list_r_fix">{{item.sfqb == '0'? "常用岗位" : "全部岗位" }}</span>
        </p>
        <p class="item">
          <span class="list_l">岗位类目</span><span class="list_r list_r_fix">{{item.gwlm}}</span>
        </p>
        <p class="item">
          <span class="list_l">求职岗位</span><span class="list_r list_r_fix">{{item.gwmc}}</span>
        </p>
        <p class="item">
          <span class="list_l">用工形式</span><span class="list_r">{{item.ygxs_xs}}</span>
        </p>
        <p class="item" v-if="item.ygxs != 40">
          <span class="list_l">期望月薪</span><span class="list_r">{{item.zdyx}}-{{item.zgyx}}</span>
        </p>
        <p class="item" v-if="item.ygxs == 40">
          <span class="list_l">期望时薪</span><span class="list_r">{{item.zdsx}}-{{item.zgsx}}</span>
        </p>
        <p class="item">
          <span class="list_l">期望就业地区</span><span class="list_r">{{item.qwjydq_xs}}</span>
        </p>
        <p class="item">
          <span class="list_l">期望企业性质</span><span class="list_r">{{item.qwqyxz_xs}}</span>
        </p>
        <p class="item" v-if="item.qwqyxz == 10">
          <span class="list_l">期望企业经济类型</span><span class="list_r">{{item.qwdjzclx_xs}}</span>
        </p>
        <p class="item" v-if="item.qwqyxz == 90">
          <span class="list_l">其他登记注册类型</span><span class="list_r">{{item.qtdjzclx_xs}}</span>
        </p>
        <p class="item">
          <span class="list_l">期望从事行业</span><span class="list_r">{{item.qwcshy_xs}}</span>
        </p>
      </div>

    </div>
    <div style="width:100%; text-align: center">
      <button class="btn addbtn" @click="editJobIntent('1')">新增求职意向</button>
    </div>
  </div>
</template>
<script>
import $ from '@/common/js/axios';

export default {
  name: 'jobIntent',
  data() {
    return {
      grqzid: '',
      qzyx: []
    };
  },
  methods: {
    /*  查询求职意向信息 */
    GET_getInfo() {
      var _this = this;
      this.$loading = true;
      this.$http.get('/grgl/grxqCx').then(res => {
        const resData = res.returnData;
        this.qzyx = resData.qzyx;
        this.grqzid = resData.jbxx.grqzid;
      }).finally(() => {
        this.$loading = false;
      });
    },
    // 编辑求职信息
    editJobIntent(czlx, item) {
      // if (!this.initEditBase) return;
      if (czlx == 1) {
        this.$router.push({
          path: "/person/baseInfo/jobedit",
          query: {grqzid: this.grqzid, ywcz: czlx}
        });
      } else {
        item.ywcz = czlx;
        item.grqzid = this.grqzid;
        this.$router.push({ path:'/person/baseInfo/jobedit', query: item  })
      }
    },
    // 删除
    deleteData(item) {
      item.grqzid = this.grqzid;
      item.ywcz = '0';
      if (this.qzyx.length <=1){
        this.$alert('求职意向至少有一条');
        return;
      }
      this.$confirm('确定要删除吗？', '提示')
      .then(() => {
        this.$loading = true;
        // this.$http.post('/url/post/grgl_qzyxBc', item).then(res => {
        this.$http.post('/grgl/qzyxBc', item).then(res => {
          const resData = res.returnData;
          this.$alert(resData.message, () => {
            this.GET_getInfo();
          });
        }).finally(() => {
          this.$loading = false;
        });
      })
      .catch(() => {
        this.$toast('选择了取消');
      });
    },
     /*  工作经历 */
    gzjl_link(){
      if (this.qzxxflag == 0) {
        if (this.jbxxflag == 0) {
          this.$alert("请填写人员信息");
        } else if (this.jbxxflag == 1) {
         this.$alert("请填写求职意向");
        }
      } else if(this.qzxxflag == 1) {
         this.$router.push({ path: "/person/baseInfo/workHistory" });
      }
    },
     /*  学习经历 */
    xxjl_link(){
      if (this.qzxxflag == 0) {
        if (this.jbxxflag == 0) {
          this.$alert("请填写人员信息");
        } else if (this.jbxxflag == 1) {
         this.$alert("请填写求职意向");
        }
      } else if(this.qzxxflag == 1){
         this.$router.push({ path: "/person/baseInfo/schoolExper" });
      }
    },
     /*  其他信息 */
    qtxx_link(){
      if (this.qzxxflag == 0) {
        if (this.jbxxflag == 0) {
          this.$alert("请填写人员信息");
        } else if (this.jbxxflag == 1) {
         this.$alert("请填写求职意向");
        }
      } else if(this.qzxxflag == 1){
         this.$router.push({ path: "/person/baseInfo/otherInfo" });
      }
    },
    async GET_personInfo() {
      const res = await this.$http.get('/grgl/sfyqzdj');
      const userInfo = res.returnData.grjbxx;
      this.$store.commit('SET_USER_INFO', {
        name: userInfo.xm,
        sfzhm: userInfo.sfzhm,
        grbh: userInfo.grbh,
        sfyjbdj: userInfo.sfyjbdj,
        sfyqzdj: userInfo.sfyqzdj
      });
      // 基本信息
    this.jbxxflag = this.$store.state.userInfo.sfyjbdj;

    // 求职信息
    this.qzxxflag = this.$store.state.userInfo.sfyqzdj;
    }
  },
  created() {
     this.GET_personInfo();
    this.GET_getInfo();
  }
};
</script>
<style scoped lang="scss">
@import '~common/scss/var.scss';
.wrap {
  .btn-wrap {
    display: flex;
    .weui-btn {
      margin: $margin-base auto;
      flex: 0 1 47%;
    }
  }
}

// 求职意向
.job_intent {
  .title {
    position: relative;
    .icon-add {
      position: absolute;
      right: 0;
      top: 0;
      padding: 0 $padding-base;
      z-index: 5;
    }
  }
}

</style>

